using System.Globalization;
using FytSoa.Common.Cache;
using FytSoa.Common.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace FytSoa.ApiService.Controllers;

[AllowAnonymous]
public class TestController: ApiController
{
    private readonly ICacheService  _cacheService;
    public TestController(ICacheService  cacheService)
    {
        _cacheService= cacheService;
    }
    [HttpGet]
    public async Task Get()
    {
        await _cacheService.SetAsync("key-a", DateTime.Now.ToString(CultureInfo.InvariantCulture), TimeSpan.FromMinutes(5));
        var value = await _cacheService.GetAsync<string>("key-a");
        Console.WriteLine($"存储的值：{value}");

        /*var cache = AppUtils.GetService<ICacheService>();
        await cache.SetAsync("key-c", "这是一个测试数据", TimeSpan.FromMinutes(5));
        var value2 = await cache.GetAsync<string>("key-c");
        Console.WriteLine($"存储的值value2：{value2}");*/
    }
}